package cn.csq.threaddemo;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @author csq
 * @version 1.0.0
 * @ClassName CreateTheadDemo4.java
 * @Description TODO
 * @createTime 2021年12月07日 22:57:00
 */
public class CreateTheadDemo4 {
    //线程池
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        ExecutorService executorService = Executors.newFixedThreadPool(10);

        executorService.execute(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println(i);
            }
        });

        Future<Integer> submit = executorService.submit(() -> {
            int i = 0;
            for (int i1 = 0; i1 < 10; i1++) {
                i = i + i1;
            }
            return i;
        });
        Integer integer = submit.get();
        System.out.println("integer = " + integer);


    }
}
